
////////////////////////////////////////////////////////////
//	File:		"SpinLock.cpp"
//	Author:		[AL] Anthony Lundquist
//	Created:	[AL] December 6, 2009
//	Purpose:	A Spin Lock for multithreading
////////////////////////////////////////////////////////////

#include "SpinLock.h"
#include <assert.h>

//#include "Helpers.h"
//#include "AL_EngineGlobals.h"

/* Data Members */

/* Constructors */

SpinLock::SpinLock() : m_bIsLocked(false)
{

}

/* Accessors */

/* Mutators */

/* Other Functions */
void SpinLock::Activate()
{
	//if(_pGlobals->IsMultiThreaded())
	{
		assert(!IsLocked());
		Lock();

		while(IsLocked());
	}
}

void SpinLock::DelayActivate()
{
	//if(_pGlobals->IsMultiThreaded())
		Lock();
}

void SpinLock::DelayLock()
{
	//if(_pGlobals->IsMultiThreaded())
	{
		assert(IsLocked());
		while(IsLocked());
	}
}

void SpinLock::Deactivate()
{
	//if(_pGlobals->IsMultiThreaded())
	{
		assert(IsLocked());
		Unlock();
	}
}

/* Destructor */

SpinLock::~SpinLock()
{

}

/* Protected Functions */

/* Private Functions */

